<?php
/**
 * 
 * Created   : 2007-10-10
 * Modified  : 2009-05-22
 * @copyright: [PhpFo.Com] (c) 2011
 * @version  : 1.0.0
 * @package  : Util.String
 * @author   : Joseph Chen (Jsph.chen@gmail.com)
 * @abstract : 字符串操作类
 * @example  :
 */
class String
{

	public static function string($num, $str)
	{
		return str_repeat($str, $num);
	}

	public static function addslashes($string)
	{
		if(is_array($string)) {
			foreach($string as $key => $val) {
				$string[$key] = self::addslashes($val, $force);
			}
		} else {
			if (is_string($string)) {
				$string = addslashes($string);
			}
		}
		return $string;
	}
	
	public static function pos_in($haystack, $needle, $logic='or') 
	{
		if (is_array($needle)) {
			foreach ($needle as $item) {
				if ($logic=='or') {//有一个匹配则返回true
					if (false !== strpos($haystack, $item)) {
						return true;
					}
				} else {
					if (false === strpos($haystack, $item)) {
						return false;
					}
				}
			}
			//关系为与的时候,能执行到这一步说明肯定都匹配,返回true
			if ($logic=='and') {
				return true;
			}
		} else {
			return strpos($haystack, $needle);
		}
		return false;
	}

	public static function strip_tags
	($string) {
		if(is_array($string)) {
			foreach($string as $key => $val) {
				$string[$key] = self::strip_tags($val, $force);
			}
		} else {
			if (is_string($string)) {
				$string = strip_tags($string);
			}
		}
		return $string;
	}
}
?>